<template>
  <el-card class="box-card">
    <el-button round class="el_btn" icon="el-icon-circle-plus-outline">添加品牌</el-button>
    <el-table v-loading="loading" :data="trademark" style="width: 100%" border>
      <el-table-column type="index" width="50" align="center" />
      <el-table-column prop="tmName" label="品牌名称" width="180" />
      <el-table-column prop="logoUrl" label="品牌LOGO" width="180" align="center">
        <template v-slot="{row}">
          <img :src="row.logoUrl" :alt="row.tmName" class="el_img">
        </template>
      </el-table-column>
      <el-table-column prop="address" label="操作">
        <el-button type="primary" icon="el-icon-circle-plus-outline" circle />
        <el-button type="danger" icon="el-icon-remove-outline" circle />
      </el-table-column>
    </el-table>
    <el-pagination
    :current-page="currentPage" 
    :page-sizes="[5, 10, 15, 20]" 
    :page-size="pageSize" 
    layout="prev, pager, next, jumper,total, sizes" 
    :total="total" 
    @size-change="handleSizeChange" 
    @current-change="handleCurrentChange"/>
  </el-card>
</template>
<script>
import { reqGetTrademarkList } from '@/api/product/trademark'
export default {
  name: 'Trademark',
  data() {
    return {
      trademark: [],
      currentPage: 1,
      pageSize: 5,
      total: 100,
      loading: false
    }
  },
  mounted() {
    this.getTrademarkList()
  },
  methods: {
    async getTrademarkList() {
      const { currentPage, pageSize } = this
      this.loading = true
      const aa = await reqGetTrademarkList(currentPage, pageSize)
      this.trademark = aa.data.records
      this.total = aa.data.total
      this.loading = false
    },

    handleSizeChange(pageSize) {
      this.pageSize = pageSize
      this.getTrademarkList()
    },

    handleCurrentChange(currentPage) {
      this.currentPage = currentPage
      this.getTrademarkList()
    }


  }

}
</script>

<style lang="scss" scoped>
.el_img {
  width: 100px;
  height: 100px;
}
</style>
